<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.List,com.wxgy.entity.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
     table{
          margin:50px auto;
     }
     td,th{
       width: 80px;
       text-align: center;
     }
     h2,h5{
      margin:20px auto;
      text-align: center;
     }
     ul{
      width:500px;
       margin:20px auto;
       padding-left:50px;
     }
     ul li{
         list-style: none;
         width: 100px;
         margin-right: 20px;
         float:left;
     }
     a:link {
	  text-decoration: none;
}
</style>
<script type="text/javascript">
   function del(){
	   return confirm("确认要删除吗？");
   }
</script>
</head>
<body>
	<%
	String errormessage=null;
	  String name=(String)session.getAttribute("username") ;
	  List<User> users=(List)request.getAttribute("list");
	 String error= (String)request.getAttribute("error");
	 int pageCount=(Integer)request.getAttribute("pageCount");
		
	 if(error!=null){
		 if(error.equals("updateok"))
			 errormessage="修改成功！";
		 else if(error.equals("updateno"))
			 errormessage="修改失败！";
		 else if(error.equals("delok"))
			 errormessage="删除成功！！";
		 else if(error.equals("delno"))
			 errormessage="删除失败！";
	 }else{
		 errormessage="";
	 }
	%>
	<h2>欢迎<%=session.getAttribute("username") %>访问！</h2>
	<h5><%=errormessage %></h5>
	<table>
		<tr><th>用户Id</th>  <th>用户名</th><th>密码</th><th>等级</th><th>修改</th><th>删除</th></tr>
		<%
		User user=null;
		 for(int i=0;i<users.size();i++){
			 user=users.get(i);
		%>
		<tr>
		   <td><%=user.getUserId() %></td>
		   <td><%=user.getUserName() %></td>
		   <td><%="******" %></td>
		   <td><%=user.getGrade() %></td>
		    <td> <a href="QueryUserByIdServlet?userId=<%=user.getUserId() %>">修改</a></td>
            <td><a onclick="return del()" href="DeleteUserById?userId=<%=user.getUserId() %>">删除</a></td></tr>
		<%} %>
	</table>
</body>
</html>